.flowchart-container {
  padding: 20px;
  height: 100vh;
  overflow: auto;
  background-color: #f5f5f5;
}

.flowchart-card {
  height: calc(100vh - 40px);
  
  .ant-card-body {
    height: calc(100% - 64px);
    display: flex;
    flex-direction: column;
    padding: 16px;
  }
}

.toolbar {
  margin-bottom: 16px;
  padding: 12px;
  background-color: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);

  .ant-btn {
    margin-right: 8px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
    
    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    }
    
    &.ant-btn-primary {
      box-shadow: 0 2px 4px rgba(24, 144, 255, 0.3);
    }
    
    &:disabled {
      transform: none;
      box-shadow: none;
      opacity: 0.5;
    }
  }

  // 按钮组样式
  .ant-btn-group {
    margin-right: 12px;
    
    .ant-btn {
      margin-right: 0;
      border-radius: 0;
      
      &:first-child {
        border-top-left-radius: 6px;
        border-bottom-left-radius: 6px;
      }
      
      &:last-child {
        border-top-right-radius: 6px;
        border-bottom-right-radius: 6px;
      }
    }
  }

  // 下拉菜单按钮
  .ant-dropdown-trigger {
    border: 1px solid #d9d9d9;
    
    &:hover {
      border-color: #40a9ff;
    }
  }

  // 网格对齐开关样式
  .ant-switch {
    margin-right: 4px;
  }

  // 响应式布局
  @media (max-width: 768px) {
    .ant-btn {
      font-size: 12px;
      padding: 4px 8px;
      height: auto;
      margin-right: 4px;
      margin-bottom: 4px;
      
      .anticon {
        font-size: 12px;
      }
    }
  }
}

.canvas-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
  background-color: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;

  /* 自定义节点样式 */
  .custom-node-wrapper {
    position: relative;
    
    .custom-node {
      cursor: pointer;
      user-select: none;
      position: relative;
      z-index: 10;
      
      &:hover {
        transform: scale(1.02);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2) !important;
      }
      
      .node-label {
        font-weight: 500;
        line-height: 1.4;
      }
      
      .node-description {
        margin-top: 4px;
        line-height: 1.3;
        word-break: break-word;
      }
    }
  }
  
  /* 连接手柄样式 */
  .react-flow__handle {
    width: 10px !important;
    height: 10px !important;
    background: #1890ff !important;
    border: 2px solid #fff !important;
    transition: all 0.2s ease !important;
    z-index: 100 !important;
    
    &:hover {
      background: #40a9ff !important;
      transform: scale(1.3) !important;
      box-shadow: 0 0 8px rgba(24, 144, 255, 0.6) !important;
    }
    
    &.react-flow__handle-top,
    &.react-flow__handle-bottom {
      left: 50% !important;
      transform: translateX(-50%) !important;
      
      &:hover {
        transform: translateX(-50%) scale(1.3) !important;
      }
    }
    
    &.react-flow__handle-left,
    &.react-flow__handle-right {
      top: 50% !important;
      transform: translateY(-50%) !important;
      
      &:hover {
        transform: translateY(-50%) scale(1.3) !important;
      }
    }
  }
  
  /* 连接状态的效果 */
  .react-flow__handle.connecting {
    background: #52c41a !important;
    box-shadow: 0 0 12px rgba(82, 196, 26, 0.8) !important;
    animation: pulse-connecting 1s infinite;
  }
  
  @keyframes pulse-connecting {
    0% {
      box-shadow: 0 0 0 0 rgba(82, 196, 26, 0.7);
    }
    70% {
      box-shadow: 0 0 0 8px rgba(82, 196, 26, 0);
    }
    100% {
      box-shadow: 0 0 0 0 rgba(82, 196, 26, 0);
    }
  }

  /* React Flow 基础样式定制 */
  .react-flow__node {
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    
    &:hover {
      box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    }
    
    &.selected {
      box-shadow: 0 0 0 2px #1890ff;
    }
  }
  
  /* 原有节点类型样式保留 */
  .react-flow__node-input {
    background-color: #52c41a;
    color: white;
    border-radius: 30px;
    border: none;
  }
  
  .react-flow__node-default {
    background-color: #1890ff;
    color: white;
    border: none;
  }
  
  .react-flow__node-output {
    background-color: #ff4d4f;
    color: white;
    border-radius: 30px;
    border: none;
  }

  /* 边线样式 */
  .react-flow__edge {
    .react-flow__edge-path {
      stroke: #1890ff;
      stroke-width: 2;
      transition: all 0.2s ease;
      
      &:hover {
        stroke: #40a9ff;
        stroke-width: 3;
      }
    }
    
    &.selected .react-flow__edge-path {
      stroke: #ff4d4f;
      stroke-width: 3;
      filter: drop-shadow(0 0 6px rgba(255, 77, 79, 0.4));
    }
    
    &.animated .react-flow__edge-path {
      stroke-dasharray: 5;
      animation: dash 1s linear infinite;
    }
  }
  
  @keyframes dash {
    to {
      stroke-dashoffset: -10;
    }
  }
  
  /* 边线标签样式 */
  .react-flow__edge-text {
    fill: #666;
    font-size: 12px;
    font-weight: 500;
  }
  
  /* 连接线的箭头样式 */
  .react-flow__arrowhead {
    fill: #1890ff;
  }
  
  .react-flow__edge.selected .react-flow__arrowhead {
    fill: #ff4d4f;
  }



  /* 控制器样式 */
  .react-flow__controls {
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    overflow: hidden;
    
    .react-flow__controls-button {
      border-bottom: 1px solid #e8e8e8;
      transition: all 0.2s ease;
      
      &:hover {
        background-color: #f0f0f0;
        transform: scale(1.05);
      }
    }
  }

  /* 迷你地图样式 */
  .react-flow__minimap {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    
    .react-flow__minimap-mask {
      fill: rgba(24, 144, 255, 0.1);
      stroke: #1890ff;
      stroke-width: 2;
    }
  }

  /* 选择框样式 */
  .react-flow__selection {
    background: rgba(24, 144, 255, 0.1);
    border: 1px dashed #1890ff;
  }

  /* 背景网格样式 */
  .react-flow__background {
    background-color: #fafafa;
  }
}

.instructions {
  margin-top: 16px;
  padding: 12px;
  background-color: #f9f9f9;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  font-size: 12px;
  color: #666;

  p {
    margin: 0 0 8px 0;
    color: #333;
    font-weight: 500;
  }

  ul {
    margin: 0;
    padding-left: 20px;

    li {
      margin-bottom: 4px;
      line-height: 1.5;
      
      strong {
        color: #1890ff;
        font-weight: 600;
      }
    }
  }
}

/* 模态框样式优化 */
.ant-modal {
  .ant-modal-header {
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 20px;
  }
  
  .ant-form-item-label {
    font-weight: 500;
  }
  
  .ant-color-picker {
    width: 100%;
  }
}

/* 抽屉样式优化 */
.ant-drawer {
  .ant-drawer-header {
    border-bottom: 1px solid #f0f0f0;
  }
  
  .ant-drawer-body {
    padding: 24px;
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .flowchart-container {
    padding: 10px;
  }

  .canvas-container {
    padding: 8px;
  }

  .toolbar {
    .ant-btn {
      font-size: 12px;
      padding: 4px 8px;
      height: auto;
      margin-right: 4px;
      margin-bottom: 4px;
    }
  }
  
  .instructions {
    font-size: 11px;
    
    ul {
      padding-left: 16px;
    }
  }
  
  /* 移动设备上的React Flow控制器 */
  .canvas-container {
    .react-flow__controls {
      bottom: 10px;
      left: 10px;
    }
    
    .react-flow__minimap {
      bottom: 10px;
      right: 10px;
      width: 120px;
      height: 80px;
    }
  }
}

/* 动画效果 */
@keyframes nodeAdded {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes nodeUpdated {
  0% {
    box-shadow: 0 0 0 0 rgba(24, 144, 255, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(24, 144, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(24, 144, 255, 0);
  }
}

@keyframes edgeAdded {
  0% {
    stroke-dasharray: 5;
    stroke-dashoffset: 5;
  }
  100% {
    stroke-dasharray: 0;
    stroke-dashoffset: 0;
  }
}

.react-flow__node {
  animation: nodeAdded 0.3s ease-out;
  
  &.updating {
    animation: nodeUpdated 0.6s ease-out;
  }
}

.react-flow__edge {
  &.new-edge {
    animation: edgeAdded 0.5s ease-out;
  }
}

/* 增强的节点样式 */
.canvas-container {
  .custom-node {
    position: relative;
    overflow: hidden;
    
    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: -100%;
      width: 100%;
      height: 100%;
      background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
      transition: left 0.5s;
    }
    
    &:hover::before {
      left: 100%;
    }
  }
  
  // 选中状态的特殊效果
  .react-flow__node.selected {
    .custom-node {
      box-shadow: 0 0 0 2px #1890ff, 0 0 20px rgba(24, 144, 255, 0.3);
      
      &::after {
        content: '';
        position: absolute;
        top: -2px;
        left: -2px;
        right: -2px;
        bottom: -2px;
        border: 2px solid #1890ff;
        border-radius: inherit;
        animation: pulse 2s infinite;
      }
    }
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(24, 144, 255, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(24, 144, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(24, 144, 255, 0);
  }
}

/* 节点类型指示器 */
.toolbar .ant-btn {
  position: relative;
  
  &::before {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
  }
  
  &[style*="#52c41a"]::before {
    background-color: #52c41a;
    opacity: 1;
  }
  
  &[style*="#1890ff"]::before {
    background-color: #1890ff;
    opacity: 1;
  }
  
  &[style*="#ff4d4f"]::before {
    background-color: #ff4d4f;
    opacity: 1;
  }
}